package com.example.fpe_vote.db2.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.fpe_vote.db2.entity.Zlemployee;
import com.example.fpe_vote.db2.mapper.ZlemployeeMapper;
import com.example.fpe_vote.db2.service.IZlemployeeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2022-12-01
 */
@Service
@DS("slave_1")
public class ZlemployeeServiceImpl extends ServiceImpl<ZlemployeeMapper, Zlemployee> implements IZlemployeeService {

    @Override
    public String querySFZByGhid(String ghid) {
        QueryWrapper<Zlemployee> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("Code",ghid);
        List<Zlemployee> zlemployees=list(queryWrapper);
        if(zlemployees==null||zlemployees.size()==0){
            return null;
        }else{
            String sfz=zlemployees.get(0).getSfz().replace(" ","");
            return sfz.substring(12);
        }
    }
}
